package com.ruoyi.supply.domain.dto;

import com.ruoyi.supply.domain.TMemberConsumeLog;
import com.ruoyi.supply.enums.MemberConsumeTypeEnum;
import com.ruoyi.supply.enums.MemberLogTypeEnum;
import lombok.Data;

import java.util.Objects;

/**
 * @author huangxiong
 * @date 2025/06/22 13:54
 */
@Data
public class ConsumeLongAttachDto {

    /**
     * 额外类型
     */
    private String attach;

    /**
     *  购买类型
     * @link com.ruoyi.supply.enums.MemberLogTypeEnum
     */
    public String buyType;

    private String id;

    public static ConsumeLongAttachDto build(Long id, MemberConsumeTypeEnum buyTypeEnum){
        ConsumeLongAttachDto consumeLongAttachDto = new ConsumeLongAttachDto();
        consumeLongAttachDto.setId(id.toString());
        switch (buyTypeEnum){
            case SOURCE:
                consumeLongAttachDto.setBuyType(MemberLogTypeEnum.BUY_SUPPLY.getCode());
                break;
            case LOCATION:
                consumeLongAttachDto.setBuyType(MemberLogTypeEnum.BUY_LOCATION.getCode());
                break;
        }

        return consumeLongAttachDto;
    }
    public static ConsumeLongAttachDto build(Long id, MemberLogTypeEnum buyTypeEnum, String attach){
        ConsumeLongAttachDto consumeLongAttachDto = new ConsumeLongAttachDto();
        consumeLongAttachDto.setId(Objects.isNull(id)?null:id.toString());
        consumeLongAttachDto.setBuyType(buyTypeEnum.getCode());
        consumeLongAttachDto.setAttach(attach);

        return consumeLongAttachDto;
    }

    public Long getIdAsLong(){
        return Long.valueOf(id);
    }

}
